// packageH/signPage/signPage.js
const app = getApp();
Page({

  data: {
    url: '',
  },

  onLoad: function (options) {
    // `https://dev1.yunzmall.com/addons/yun_shop/?menu#/${'signPage/99'}?i=2`
    let url = "";
    if(options.url) {
      // 认证页面跳转
      url = options.url;
    }else if(options.id){
      url = this.getShopUrl(options);
    }else {
      wx.navigateBack({
        delta: 1,
      });
    }
    
    this.setData({
      url: url
    });
  },
  getShopUrl(options){
    let url;
    let wx_token = wx.getStorageSync('wx_token');
    if(options.from != 'signV2') url = app.globalData.host + `/addons/yun_shop/?menu#/signPagePlu/${options.id}?i=` + app.globalData.uniacid;
    if(options.from == 'signV2') url = app.globalData.host + `/addons/yun_shop/?menu#/signPage/${options.id}?i=` + app.globalData.uniacid +'&from=signV2&scene=' + options.scene + "&cid=" + options.cid + "&oid=" + options.oid;
    if(options.fromOrder){
      url = url + '&fromOrder=1'
    }
    url = `${url}&min_token=${wx_token}`;//自营商城免登录
    return url;
  },
  // 刷脸完成后重新加载实名页面
  reloadPage(redirectUrl) {
    console.log('---webview reloadPage----', redirectUrl);
    this.setData({
      url: redirectUrl
    })
  },


  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    if(this.options.fromOrder){
      let pages = getCurrentPages();
      let prevPage = pages[pages.length - 2]; //上一个页面    -3就是上上一个页面
      prevPage.getShopSign();
    }
  },

});